import React from 'react'
import { useSearchParams } from 'react-router-dom'

const Detail = function () {
  // 组路由接收search参数 通过useSearchParams方法
  let [searchParams] = useSearchParams();
  let id = searchParams.get("id");
  let title = searchParams.get("title");
  const DetailData = [
    {id:'01', content: '你好,中国'},
    {id:'02', content: '你好,react'},
    {id:'03', content: '你好,未来的自己'},
  ];
  console.log(id, title);
  const findResult = DetailData.find((item) => {
    return item.id === id
  })
  return (
    <>
      <li>ID: {id}</li>
      <li>TITLE: {title}</li>
      <li>CONTENT: {findResult.content}</li>
    </>
  )
}
export default Detail;
